cmake_minimum_required(VERSION 3.8)
project(rm_detector)


set(CMAKE_CXX_STANDARD 17)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# 查找 ROS 2 核心依赖
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(image_transport REQUIRED)
find_package(OpenCV REQUIRED)



# 添加头文件搜索路径
include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}/src/${PROJECT_NAME}
  ${CMAKE_CURRENT_SOURCE_DIR}/src/${PROJECT_NAME}/include
  ${OpenCV_INCLUDE_DIRS}
  ${cv_bridge_INCLUDE_DIRS}
)

# 添加可执行文件
add_executable(rm_detector_node  
  src/detector_node.cpp
  src/rm_detector_node.cpp
)

# 链接 ROS 2 和 OpenCV 库
ament_target_dependencies(rm_detector_node
  rclcpp
  sensor_msgs
  cv_bridge
  image_transport
  OpenCV
)

# 安装目标
install(TARGETS
  rm_detector_node
  DESTINATION lib/${PROJECT_NAME}
)
install(DIRECTORY
  launch
  DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  set(ament_cmake_copyright_FOUND TRUE)
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
